;
(function (call) {
    var main = {
        mapId: "tjMap",
        intervalFlag: "",
        productList: [],
        currentList: [],
        router: {
            getProductList: 'sjyb/pic/list',
        },
        init: function () {
            this.initView();
            this.bindEvt();
        },
        initView: function () {
            var model = $(".product-szyb-tab ul li.active").data("model");
            if (model.fullname == 'TJWRF') {
                $(".areaCN,.areaHB").hide();
                $(".areaHB").removeClass('active');
                $(".areaHH").addClass('active');
            } else {
                $(".areaCN,.areaHB").show();
            }

            if (model.fullname === 'EC') {
                $('.product-pic-ec-handle').show();
            } else {
                $('.product-pic-ec-handle').hide();
            }
            this.initProduct(1);
        },
        // 获取请求参数
        getReqParam: function () {
            var proInfo = $(".product-pic-tab li.active").data('pro');
            if (!proInfo)
                proInfo = $(".product-pic-tab td.active").data('pro');
            var model = $(".product-szyb-tab ul li.active").data("model").fullname;
            if (model == "EC") {
                model = "ECMF"
            }
            var param = {
                model: proInfo.model || model,
                element: proInfo.ele_id,
                productType: proInfo.height ? 'PB' : (proInfo.type || 'PB'),
                time: $("#date.DateAgent").val() + ":00:00",
                area: $(".product-pic-tools li.active").attr('area'),
                height: proInfo.height ? proInfo.height.replace('k', '') : '000',
                interval: 3,
                isNew: 0
            }
            return param;
        },
        // 获取产品图
        initProduct: function (isNew) {
            var that = this;
            var proInfo = $(".product-pic-tab li.active").data('pro');
            if (!proInfo)
                proInfo = $(".product-pic-tab td.active").data('pro');
            var legendPic = proInfo.legend_pic;
            var legendType = proInfo.lengendType || ''
            debugger
            if (legendType != '') {
                if (legendPic) {
                    if (legendType == '1') {
                        $(".legend-pic").attr("src", '../business/szyb/css/images/product-legend/' + 'fengqingWind.png' + '').show();
                    } else {
                        $(".legend-pic").attr("src", '../business/szyb/css/images/product-legend/' + 'fengqingWet.png' + '').show();
                    }
                } else {
                    $(".legend-pic").hide();
                }
            } else {
                if (legendPic) {
                    $(".legend-pic").attr("src", '../business/szyb/css/images/product-legend/' + legendPic + '').show();
                } else {
                    $(".legend-pic").hide();
                }
            }

            let params = that.getReqParam();
            params.isNew = 0;
            var model = $(".product-szyb-tab ul li.active").data("model").fullname;
            if (model != '风清') {
                $.getJSON(that.router.getProductList, params, function (res) {
                    if (res.isSuccess) {
                        var data = res.data;
                        if (data.length > 0) {
                            data.map(item => {
                                if (item.picUrl && item.picUrl.indexOf("/zht") != -1) {
                                    item.picUrl = item.picUrl.substring(item.picUrl.indexOf("/zht"))
                                }
                            })
                            that.productList = data;
                            that.bulidTimeLine(data);
                        } else {
                            alert('无产品图');
                        }
                    }
                });
            } else {
                var requestData = {
                    period: 6,
                    queryTime: formatDateTime(params.time),
                    element: params.element,
                    range: params.area
                }
                $.ajax({
                    url: 'raw/ysqMakeImg/FQMakeImg',
                    type: 'POST',
                    data: requestData,
                }).done(function (res) {
                    var data = res.data;
                    const buildData = [
                        {
                            interval: '0',
                            legend: null,
                            newTime: null,
                            picUrl: `data:image/png;base64,${res}`,
                            time: params.time,
                            timeRange: null,
                            model: '风清'
                        }
                    ]
                    debugger
                    that.bulidTimeLine(buildData);
                    // var imgUrl = base64ToImage(data)
                    if (res.data != '') {
                        that.bulidTimeLine(buildData);
                    } else {
                        alert('无产品图');
                    }
                })
            }
            function base64ToImage(base64String) {
                var img = new Image();
                img.onload = function () {
                    var canvas = document.createElement("canvas");
                    canvas.width = img.width;
                    canvas.height = img.height;
                    var ctx = canvas.getContext("2d");
                    ctx.drawImage(img, 0, 0);
                    var newBase64String = canvas.toDataURL();
                };
                img.src = base64String;
                return img
            }
            function formatDateTime(dateString) {
                const date = new Date(dateString);
                const year = date.getFullYear();
                const month = (date.getMonth() + 1).toString().padStart(2, '0');
                const day = date.getDate().toString().padStart(2, '0');
                const hours = date.getHours().toString().padStart(2, '0');
                const minutes = date.getMinutes().toString().padStart(2, '0');
                const seconds = date.getSeconds().toString().padStart(2, '0');
                return `${year}${month}${day}${hours}${minutes}${seconds}`
            }
        },
        // 构建时间轴
        bulidTimeLine: function (data) {
            this.currentList = JSON.parse(JSON.stringify(data));
            var $timeLi;
            var selectedIndex = $("#product-timeLine li.active").index();
            if (selectedIndex < 0) selectedIndex = 0;
            var $timeLine = $("#product-timeLine").empty();
            var area = $('.product-pic-tools ul li.active').attr('area')
            var hiddenTime = $(".product-pic-footer")
            data.forEach(function (item, index) {
                if (item.model == '风清') {
                    hiddenTime.addClass('hidden')
                    $timeLi = $(`<li title="${item.time}">${new Date(item.time).format("ddhh")}</li>`);
                    $timeLi.off().click(function () {
                        $(".model-pic").removeClass('hidden').attr('src', item.picUrl);
                    })
                    $timeLine.append($timeLi);
                } else {
                    $timeLi = $(`<li title="${item.time}">${new Date(item.time).format("ddhh")}</li>`);
                    $timeLi.off().click(function () {
                        $(".model-pic").removeClass('hidden').attr('src', item.picUrl);
                        $(".model-pic-bj").removeClass('hidden').attr('src', '../business/szyb/css/images/' + area + '.png');
                    }).data({ "url": item.picUrl, "val": item.time, "interval": item.interval });
                    $timeLine.append($timeLi);
                }
            })
            $timeLine.find("li").eq(selectedIndex).trigger("click");
        },
        //标题展示
        buildProductTitle: function () {
            var ybTime = new Date($("#product-timeLine li.active").attr('title')).format('yyyy-MM-dd hh:mm');
            var model = $(".product-szyb-tab ul li.active").data("model").name;
            var proInfo = $(".product-pic-tab li.active").data('pro');
            if (!proInfo)
                proInfo = $(".product-pic-tab td.active").data('pro');
            var name = proInfo.ele_name;
            //var title = [ybTime];
            var title = [ybTime, model, name];
            return title.join("&nbsp;");
        },
        //标题展示
        buildProductTitle2: function () {
            var ybTime = new Date($("#product-timeLine li.active").attr('title')).format('yyyy-MM-dd hh:mm');
            var model = $(".product-szyb-tab ul li.active").data("model").name;
            var proInfo = $(".product-pic-tab li.active").data('pro');
            if (!proInfo)
                proInfo = $(".product-pic-tab td.active").data('pro');
            var name = proInfo.ele_name;
            var title = [ybTime];
            //var title = [ybTime, model, name];
            return title.join("&nbsp;");
        },
        bindEvt: function () {
            var that = this;
            // 时间轴点击事件
            $("#product-timeLine").delegate('li', 'click', function () {
                $(this).addClass("active").siblings().removeClass("active");
                $(".product-pic-title").html(that.buildProductTitle());
                $(".product-pic-title2").html(that.buildProductTitle2());
            })
            $(".product-play-time i").click(function () {
                $(this).addClass("active").siblings().removeClass("active");
            });
            $(".product-control-btn").click(function () {
                if ($(this).hasClass('play')) {
                    var time = Number($(".product-play-time i.active").text()) * 1000;
                    that.intervalFlag = setInterval(function () {
                        if ($(".product-timeLine li.active").next().length > 0)
                            $("#next").click();
                        else
                            $(".product-control-btn").trigger('click');
                    }, time)
                    $(this).removeClass("play").addClass("suspend");
                } else {
                    clearInterval(that.intervalFlag);
                    $(this).removeClass("suspend").addClass("play");
                }
            });
            $(".product-pic-download").click(function () {
                Html2Canvas.Save($(".product-pic-view"), function () { });
            });
            // 时间轴上一页
            $("#prev").click(function () {
                var len = $("#product-timeLine li").length; // 时间总个数
                var index = $("#product-timeLine li.active").index(); // 当前选中时间的下标
                var left = Number($(".product-timeLine ul").css("left").replace("px", ''));
                if (index == 0) return;
                var offsetLeft = $("#product-timeLine li.active").offset().left;
                if (offsetLeft == 12 * 45) {
                    $(".product-timeLine ul").css("left", left + 45 * 10);
                }
                $("#product-timeLine li.active").prev().click();
            })
            // 时间轴下一页
            $("#next").click(function () {
                var len = $("#product-timeLine li").length;
                var index = $("#product-timeLine li.active").index();
                var left = Number($(".product-timeLine ul").css("left").replace("px", ''));
                if (index == len - 1) return;
                if (index >= 20 && Math.abs(left) == (index - 20) * 45) {
                    $(".product-timeLine ul").css("left", (left - 45 * 10));
                }
                $("#product-timeLine li.active").next().click();
            })
            $('.product-pic-view').hover(
                function () {
                    $(".product-pic-prev,.product-pic-next").show();
                },
                function () {
                    $(".product-pic-prev,.product-pic-next").hide();
                }
            )
            // 向前
            $(".product-pic-prev").click(function () {
                $("#prev").trigger('click');
            })
            // 向后
            $(".product-pic-next").click(function () {
                $("#next").trigger('click');
            })
            $(".product-pic-tools ul li").click(function () {
                $(this).toggleClass('active').siblings().removeClass('active');
                if ($(this).hasClass('active')) {
                    that.initProduct(1);
                }
            })
            $("#modal_product_pic .close").click(function () {
                clearInterval(that.intervalFlag);
            })
            $(".titleIcon").click(function () {
                if ($(this).hasClass("active")) {
                    $(this).removeClass("active");
                    $(".product-pic-title2").hide();
                    that.isSHowTitle
                } else {
                    $(this).addClass("active");
                    $(".product-pic-title2").show();
                }
            })

            $('.product-pic-ec-handle-confirm').off('click').on('click', function () {
                let checkboxValue = $('#ecHandleCheckbox').is(':checked');
                let startTimeValue = $('#ecHandleStartTime').val();
                let endTimeValue = $('#ecHandleEndTime').val();
                let intervalValue = $('#ecHandleInterval').val();

                let checkboxValue2 = $('#ecHandleCheckbox2').is(':checked');
                let startTimeValue2 = $('#ecHandleStartTime2').val();
                let endTimeValue2 = $('#ecHandleEndTime2').val();
                let intervalValue2 = $('#ecHandleInterval2').val();

                let currentTime = new Date(that.getReqParam().time);
                if (checkboxValue && checkboxValue2) {
                    let isValid = that.isMultipleOfThree(startTimeValue) && that.isMultipleOfThree(endTimeValue) && that.isMultipleOfSix(startTimeValue2) && that.isMultipleOfSix(endTimeValue2) && (startTimeValue < endTimeValue) && (endTimeValue < startTimeValue2) && (startTimeValue2 < endTimeValue2);
                    if (!isValid) return alert('输入无效，请确保所有输入都是3或6的倍数，并且满足条件：开始时间小于结束时间');

                    let start1 = new Date(currentTime.getTime() + startTimeValue * 60 * 60 * 1000);
                    let end1 = new Date(currentTime.getTime() + endTimeValue * 60 * 60 * 1000);
                    let data1 = that.productList.filter(el => new Date(el.time) >= start1 && new Date(el.time) <= end1 && el.interval % intervalValue === 0);

                    let start2 = new Date(currentTime.getTime() + startTimeValue2 * 60 * 60 * 1000);
                    let end2 = new Date(currentTime.getTime() + endTimeValue2 * 60 * 60 * 1000);
                    let data2 = that.productList.filter(el => new Date(el.time) >= start2 && new Date(el.time) <= end2 && el.interval % intervalValue2 === 0);

                    that.bulidTimeLine([...data1, ...data2]);
                    return;
                }

                if (checkboxValue) {
                    let isValid = that.isMultipleOfThree(startTimeValue) && that.isMultipleOfThree(endTimeValue) && (+startTimeValue < +endTimeValue);
                    if (!isValid) return alert('输入无效，请确保所有输入都是3的倍数，并且满足条件：开始时间小于结束时间');

                    let start1 = new Date(currentTime.getTime() + startTimeValue * 60 * 60 * 1000);
                    let end1 = new Date(currentTime.getTime() + endTimeValue * 60 * 60 * 1000);
                    let data1 = that.productList.filter(el => new Date(el.time) >= start1 && new Date(el.time) <= end1 && el.interval % intervalValue === 0);

                    that.bulidTimeLine(data1);
                    return;
                }

                if (checkboxValue2) {
                    let isValid = that.isMultipleOfSix(startTimeValue2) && that.isMultipleOfSix(endTimeValue2) && (+startTimeValue2 < +endTimeValue2);
                    if (!isValid) return alert('输入无效，请确保所有输入都是6的倍数，并且满足条件：开始时间小于结束时间');
                    
                    let start2 = new Date(currentTime.getTime() + startTimeValue2 * 60 * 60 * 1000);
                    let end2 = new Date(currentTime.getTime() + endTimeValue2 * 60 * 60 * 1000);
                    let data2 = that.productList.filter(el => new Date(el.time) >= start2 && new Date(el.time) <= end2 && el.interval % intervalValue2 === 0);

                    that.bulidTimeLine(data2);
                    return;
                }
            });

            $('.product-pic-ec-handle-reset').off('click').on('click', function () {
                $('#ecHandleCheckbox, #ecHandleCheckbox2').prop('checked', true);
                $('#ecHandleStartTime').val('0');
                $('#ecHandleEndTime').val('72');
                $('#ecHandleInterval').val('3');
                $('#ecHandleStartTime2').val('78');
                $('#ecHandleEndTime2').val('240');
                $('#ecHandleInterval2').val('6');
                $('#ecHandleStartTime, #ecHandleEndTime, #ecHandleInterval, #ecHandleStartTime2, #ecHandleEndTime2, #ecHandleInterval2').prop('disabled', false);
                that.bulidTimeLine(that.productList);
            });

            $('#ecHandleCheckbox').change(function() {
                let isChecked = $('#ecHandleCheckbox').is(':checked');
                $('#ecHandleStartTime, #ecHandleEndTime, #ecHandleInterval').prop('disabled', !isChecked);
            });

            $('#ecHandleCheckbox2').change(function() {
                let isChecked = $('#ecHandleCheckbox2').is(':checked');
                $('#ecHandleStartTime2, #ecHandleEndTime2, #ecHandleInterval2').prop('disabled', !isChecked);
            });

            $('.product-pic-ec-handle-download').click(function (e) {
				e.stopPropagation();
				let frames = [];
				let currentIndex = 0;
				let gif;
				let isProcessing = false;
                if (!loading.isExist()) loading.add();
                //临时禁用 AMD 定义
                window.__define = window.define;
                window.define = undefined;
                $.getScript('/business/szyb/gif.js', function() {
                    let proInfo = $(".product-pic-tab li.active").data('pro');
                    if (!proInfo) proInfo = $(".product-pic-tab td.active").data('pro');
                    intervalTime = Number($('.product-play-time i.active').text()) * 1000;
                    console.log('that.currentList======>', that.currentList);

                    if (isProcessing) return;
                    startGIFGeneration();

                    function startGIFGeneration() {
                        isProcessing = true;
                        frames = [];
                        currentIndex = 0;
                        processNextImage();
                    }

                    function processNextImage() {
                        console.log('processNextImage======>', currentIndex, that.currentList.length, frames.length);
                        if (currentIndex >= that.currentList.length) {
                            finishGIFGeneration();
							currentIndex = 0;
							frames = [];
							isProcessing = false;
                            return;
                        }

                        // Load the next image
                        $('#productModelPicImg').attr('src', that.currentList[currentIndex].picUrl).off('load').on('load', function() {
                            $('.product-pic-title').text(`${new Date(that.currentList[currentIndex].time).format('yyyy-MM-dd hh:mm')} ${proInfo.ele_name}`);
                            $('.product-pic-title2').text(new Date(that.currentList[currentIndex].time).format('yyyy-MM-dd hh:mm'));
                            setTimeout(captureFrame, 1000);
                        }).off('error').on('error', function() {
                            currentIndex++;
                            setTimeout(processNextImage, 1000);
                        });
                    }

                    function captureFrame() {
                        html2canvas($('#productPicView')[0], {
                            useCORS : true,
                            allowTaint : false,
                            logging : true,
                            background: '#ffffff',
                            onrendered: canvas => {
                                frames.push(canvas);
                                // Move to next image
                                currentIndex++;
                                setTimeout(processNextImage, 1000); // Small delay between captures
                            }
                        });
                    }

                    function finishGIFGeneration() {
                        if (gif) {
                            gif.abort();
                            gif = null;
                        }
                    
                        gif = new GIF({
                            workers: 2, // 设置工作线程数，默认为2
                            quality: 10, // 设置GIF质量，1-100，默认是10
                            width: 1190, // 设置GIF宽度
                            height: 740, // 设置GIF高度
                            workerScript: '/business/szyb/gif.worker.js', // 设置工作线程脚本路径
                        });
                        // Add all frames to GIF
                        frames.forEach((frame, index) => {
                            gif.addFrame(frame, {delay: intervalTime, copy: true});
                        });
        
                        // Render the GIF
                        gif.on('finished', function(blob) {
							currentIndex = 0;
							frames = [];
							isProcessing = false;
                            loading.remove();
                            const url = URL.createObjectURL(blob);
                            const a = document.createElement('a');
                            a.href = url;
                            a.download = `EC-${proInfo.ele_name}.gif`;
                            document.body.appendChild(a);
                            a.click();
                            gif.abort();
                            setTimeout(() => {
                                document.body.removeChild(a);
                                window.URL.revokeObjectURL(url);
                            }, 100);
                            
							$('#product-timeLine li').removeClass('active').last().addClass('active');
                            $('#productModelPicImg').off('load');
                            $('#productModelPicImg').off('error');
                        });
        
                        gif.on('error', function(e) {
                            loading.remove();
                            gif.abort();
							currentIndex = 0;
							frames = [];
							isProcessing = false;
                            $('#productModelPicImg').off('load');
                            $('#productModelPicImg').off('error');
                        });
        
                        gif.render();
                    }
                });
            });
            
            // $('.product-pic-ec-handle-download').off('click').on('click', function () {
            //     let frames = [];
            //     let currentIndex = 0;
            //     let totalUpdates = that.currentList.length;
            //     let intervalTime = 0;
            //     let captureInterval;
            //     let gif;
            //     console.log('that.currentList======>', that.currentList);

            //     if (!loading.isExist()) loading.add();
            //     //临时禁用 AMD 定义
            //     window.__define = window.define;
            //     window.define = undefined;
            //     $.getScript('/business/szyb/gif.js', function() {
            //         try {
            //             gif = new GIF({
            //                 workers: 2, // 设置工作线程数，默认为2
            //                 quality: 10, // 设置GIF质量，1-100，默认是10
            //                 width: 1190, // 设置GIF宽度
            //                 height: 740, // 设置GIF高度
            //                 workerScript: '/business/szyb/gif.worker.js', // 设置工作线程脚本路径
            //             });

            //             let proInfo = $(".product-pic-tab li.active").data('pro');
            //             if (!proInfo) proInfo = $(".product-pic-tab td.active").data('pro');
            //             intervalTime = Number($('.product-play-time i.active').text()) * 1000;
            //             frames = [];
            //             currentIndex = 0;
            //             // Show the first image
            //             updateImageAndCapture();
            //             // Set interval for subsequent updates
            //             captureInterval = setInterval(updateImageAndCapture, intervalTime);

            //             function updateImageAndCapture() {
            //                 if (currentIndex >= totalUpdates) {
            //                     clearInterval(captureInterval);
            //                     generateGIF();
            //                     return;
            //                 }
            
            //                 // Update the image source
            //                 let item = that.currentList[currentIndex % that.currentList.length];
            //                 $('.model-pic').attr('src', item.picUrl).on('load', () => {
            //                     console.log('load======>');
            //                     $('.product-pic-title').text(`${new Date(item.time).format('yyyy-MM-dd hh:mm')} ${proInfo.ele_name}`);
            //                     $('.product-pic-title2').text(item.time);
            //                     captureFrame();
            //                 });
            //                 currentIndex++;
            //             }

            //             function captureFrame() {
            //                 html2canvas($('#productPicView')[0], {
            //                     useCORS : true,
            //                     allowTaint : false,
            //                     logging : true,
            //                     background: '#ffffff',
            //                     onrendered: canvas => {
            //                         frames.push(canvas);
            //                     }
            //                 });
            //             }

            //             function generateGIF() {
            //                 console.log('generateGIF======>', frames.length);
            //                 gif.abort();
            //                 gif = new GIF({
            //                     workers: 2, // 设置工作线程数，默认为2
            //                     quality: 10, // 设置GIF质量，1-100，默认是10
            //                     width: 1190, // 设置GIF宽度
            //                     height: 700, // 设置GIF高度
            //                     workerScript: '/business/szyb/gif.worker.js', // 设置工作线程脚本路径
            //                 });

            //                 gif.on('finished', blob => {
            //                     // Create download link
            //                     let url = URL.createObjectURL(blob);
            //                     let a = document.createElement('a');
            //                     a.href = url;
            //                     a.download = `EC-${proInfo.ele_name}.gif`;
            //                     document.body.appendChild(a);
            //                     a.click();
            //                     setTimeout(function() {
            //                         document.body.removeChild(a);
            //                         window.URL.revokeObjectURL(url);
            //                         loading.remove();
            //                     }, 100);
            //                 });
            //                 // Add each frame to the GIF
            //                 frames.forEach((canvas, index) => {
            //                     gif.addFrame(canvas, {delay: intervalTime, copy: true});
            //                 });
            //                 gif.render();
            //             }
            //         } catch (err) {
            //             console.error('err======>', err);
            //         }
            //     });
            // });

            // $('.product-pic-ec-handle-download').off('click').on('click', function () {
            //     if (!loading.isExist()) loading.add();
            //     $('.product-pic-view').hide();
            //     $('.gif-content').show();
            //     //临时禁用 AMD 定义
            //     window.__define = window.define;
            //     window.define = undefined;
            //     $.getScript('/business/szyb/gif.js', function() {
            //         try {
            //             let gif = new GIF({
            //                 workers: 2, // 设置工作线程数，默认为2
            //                 quality: 10, // 设置GIF质量，1-100，默认是10
            //                 width: 1190, // 设置GIF宽度
            //                 height: 740, // 设置GIF高度
            //                 workerScript: '/business/szyb/gif.worker.js', // 设置工作线程脚本路径
            //             });

            //             let proInfo = $(".product-pic-tab li.active").data('pro');
            //             if (!proInfo) proInfo = $(".product-pic-tab td.active").data('pro');
            //             let legendPic = proInfo.legend_pic;
            //             let area = $('.product-pic-tools ul li.active').attr('area');
            //             let time = Number($('.product-play-time i.active').text()) * 1000;
            //             that.currentList.forEach((el, index) => {
            //                 let $div = $(`
            //                     <div id="ecPic${index}" class="product-pic-view-gif">
            //                         <div class="gif-title">${new Date(el.time).format('yyyy-MM-dd hh:mm')}&nbsp;EC&nbsp;${proInfo.ele_name}</div>
            //                         <div class="gif-time-item">${el.time}</div>
            //                         <img class="gif-img" src="${el.picUrl}" />
            //                         <img class="gif-bj" src="../business/szyb/css/images/${area}.png" />
            //                     </div>
            //                 `);
            //                 legendPic && $div.append($(`<img class="gif-legend" src="../business/szyb/css/images/product-legend/${legendPic}"></img>`));
            //                 $('.gif-content').append($div);
            //             });

            //             that.currentList.forEach((el, index) => {
            //                 let canvas = document.createElement('canvas');
            //                 canvas.width = 1190;
            //                 canvas.height = 740;
            //                 html2canvas(document.getElementById(`ecPic${index}`), {
            //                     useCORS : true,
            //                     allowTaint : false,
            //                     logging : true,
            //                     canvas: canvas,
            //                     onrendered: function(cv) {
            //                         console.log('toDataURL======>', cv.toDataURL());
            //                         gif.addFrame(cv, { copy: true, delay: time });
            //                         $(`#ecPic${index}`).remove();
            //                         if (index === that.currentList.length - 1) {
            //                             gif.render(); // 开始渲染GIF动画
            //                         }
            //                     }
            //                 })
            //             });
    
            //             gif.on('finished', function(blob) {
            //                 let a = document.createElement('a');
            //                 a.href = URL.createObjectURL(blob);
            //                 a.download = `EC-${proInfo.ele_name}.gif`;
            //                 a.click();
            //                 gif.abort();
            //                 $('.product-pic-view').show();
            //                 loading.remove();
            //             });
            //             //恢复 AMD 定义（如果有其他库需要）
            //             window.define = window.__define;
            //         } catch (err) {
            //             console.error('err======>', err);
            //         }
            //     });
            // });
        },
        isMultipleOfThree: function(num) {
            return +num % 3 === 0;
        },
        isMultipleOfSix: function(num) {
            return +num % 6 === 0;
        }
    };
    if (typeof call === 'function') {
        window.productPic = main;
        call(main);
    }
})(function (main) {
    CafeJS.models(['datepicker'], function () {
        main.init();
    });
});